package com.sudo.common.utils;

import java.nio.charset.StandardCharsets;
import java.util.Base64;

public class Base64Util {
    private Base64Util(){}
    private static final Base64.Encoder encoder = Base64.getEncoder();
    private static final Base64.Decoder decoder = Base64.getDecoder();

    public static String encode(String txt) {
        byte[] bytes = txt.getBytes(StandardCharsets.UTF_8);
        return encoder.encodeToString(bytes);
    }

    public static String decode(String encodeTxt) {
        byte[] bytes = decoder.decode(encodeTxt);
        return new String(bytes,StandardCharsets.UTF_8);
    }
}
